<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="${path}/static/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${path}/static/css/font-awesome.min.css">
    <link rel="stylesheet" href="${path}/static/css/main.css">
    <link rel="stylesheet" href="${path}/static/css/doc.min.css">
    <link rel="stylesheet" href="${path}/static/ztree/zTreeStyle.css">
    <style>
        .tree li {
            list-style-type: none;
            cursor:pointer;
        }
    </style>
</head>

<body>

<%-- 顶部导航 --%>
<jsp:include page="${path}/static/nav.jsp"></jsp:include>

<div class="container-fluid">
    <div class="row">

        <%--  左侧导航栏  --%>
        <jsp:include page="${path}/static/left.jsp"></jsp:include>

        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">

            <div class="panel panel-default">
                <div class="panel-heading">
                    <i class="glyphicon glyphicon-th-list"></i> 权限菜单列表
                    <div style="float:right;cursor:pointer;" data-toggle="modal" data-target="#myModal"><i class="glyphicon glyphicon-question-sign"></i>
                    </div>
                </div>

                <div class="panel-body">
                    <button class="btn btn-success">分配许可</button>
                    <br><br>
                    <ul id="treeDemo" class="ztree">

                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="${path}/static/jquery/jquery-2.1.1.min.js"></script>
<script src="${path}/static/bootstrap/js/bootstrap.min.js"></script>
<script src="${path}/static/script/docs.min.js"></script>
<script src="${path}/static/ztree/jquery.ztree.all-3.5.min.js"></script>
<script src="${path}/static/layer/layer.js"></script>
<script type="text/javascript">

    var setting={
        check : {
            enable : true
        },
        view: {
            selectedMulti: false,
            addDiyDom: function(treeId, treeNode){
                var icoObj = $("#" + treeNode.tId + "_ico"); // tId = permissionTree_1, $("#permissionTree_1_ico")
                if ( treeNode.icon ) {
                    icoObj.removeClass("button ico_docu ico_open").addClass("fa fa-fw " + treeNode.icon).css("background","");
                }
            },
        },
        async:{
            //是否异步请求
            enable: true,
            //数据地址
            url:"${path}/permission/list",
            //将permission作为参数查找子信息
            autoParam:["permissionid"]
        },
        callback: {
            onClick : function(event, treeId, json) {
            }
        }
    };

    $(function () {
        $(".list-group-item").click(function(){
            if ( $(this).find("ul") ) {
                $(this).toggleClass("tree-closed");
                if ( $(this).hasClass("tree-closed") ) {
                    $("ul", this).hide("fast");
                } else {
                    $("ul", this).show("fast");
                }
            }
        });

        //使用zTree
        $.fn.zTree.init($("#treeDemo"),setting);

    });


</script>
</body>
</html>
